const { default: axios } = require('axios');

const router = require('express').Router()

/**
 * @api {get} /video 获取视频数据
 * @apiName 获取视频数据
 * @apiGroup video(视频相关)
 * @apiDescription 获取视频数据
 * @apiVersion  1.0.0
 * @apiParam {String} feedChannelId=''  栏目Id
 * @apiParam {String} timestamp=''  当前时间戳
 * 
 * @apiParamExample  {type} 请求示例:
 * {  
 *    feedChannelId:10086,
 *    timestamp:1644580679062,
 * }
 * 
 * @apiSuccess {Number} code 200
 * @apiSuccess {Object} datas 数据信息
 * @apiSuccessExample {type} 返回示例:
 * {
     code:200
     data: {
            video: [{
                    "alreadyUp": false,
                    "commentCount": 0,
                    "converterType": 1,
                    "dataSource": 1,
                    "eventTracking": "video",
                    "id": 9198526,
                    "images": [
                        {
                            "hight": 360,
                            "id": 30863,
                            "url": "http://p1.meituan.net/movie/79f32a13cd2fe28a9d38ebc6937e8a4c26339.jpg",
                            "weight": 640
                        }
                    ],
                    "imgCount": 1,
                    "onlineTime": 1644542722000,
                    "product": {
                        "productId": 1297,
                        "type": 0
                    },
                    "shareCount": 40,
                    "shareInfo": {
                        "channel": 4,
                        "content": "猫眼电影",
                        "img": "http://p1.meituan.net/movie/79f32a13cd2fe28a9d38ebc6937e8a4c26339.jpg",
                        "title": "安迪决定改变“命运”的时刻"
                    },
                    "style": 4,
                    "title": "安迪决定改变“命运”的时刻",
                    "type": 2,
                    "upCount": 98,
                    "user": {
                        "avatarurl": "https://img.meituan.net/avatar/0fa336d1000a3ec48505276a5dcfa7bb65723.jpg",
                        "followed": false,
                        "identification": 1,
                        "nickName": "口袋电影",
                        "userId": 1095729574
                    },
                    "video": {
                        "dur": 68,
                        "height": 720,
                        "id": 9198526,
                        "imgUrl": "http://p1.meituan.net/movie/79f32a13cd2fe28a9d38ebc6937e8a4c26339.jpg",
                        "url": "https://vod.pipi.cn/fec9203cvodtransbj1251246104/2014aef7387702295902883720/v.f42905.mp4",
                        "viewCount": 0,
                        "width": 1278
                    }
                }],
     msg: "ok"
  },
}
 * 
 */
router.get('/video', (req, res) => {
    let { feedChannelId, timestamp } = req.query
    console.log(feedChannelId,timestamp);
    axios.get(`https://i.maoyan.com/asgard/asgardapi/sns/common/feed/channel/list.json?uuid=EB4A7DD07B3A11EC95D225E4C50915F774EC1F35A8CB47F499851D0C3CBCFA4F&channelId=4&feedChannelId=${feedChannelId}&timestamp=${timestamp}&offset=15`).then(datas=>{
        let videos = datas.data.data.feeds
        res.send({code:200,videos,msg:'ok'})
    })
  
})


module.exports = router